<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>修改</button>
    <script>
        let a = 132
        console.log(a);
        document.querySelector('button').onclick = function(){
            a=456
             console.log(a);
              localStorage.setItem('token',new Date().getTime())
                // 设置一条会话存储
              sessionStorage.setItem('text','谁在说话')
        }
        // // 数据持久化存储 刷新不会丢失  永远不会丢失 
        // localStorage.setItem('token',123456)
        // 获取本地存储
        console.log(localStorage.getItem('token'));

        // 会话存储 浏览器关闭的时候会消失
        // sessionStorage.setItem('text','谁在说话')
        console.log(sessionStorage.getItem('text'));

        let arr = [
            {
                name:"张三"
            }
        ]

        localStorage.setItem('arr',arr)
        console.log(localStorage.getItem('arr'));
        // 删除缓存
        localStorage.removeItem('arr')
        // sessionStorage 和localStorage 存储的数据均为字符串类型
        
        
        
        
    </script>
</body>
</html>